🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

singleline

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

singleline

Convert a multi line string into a single line string - great for classnames and more

2.0.2
latest
Source
npm
Version published
Weekly downloads
0
Maintainers
0
Weekly downloads
 
Created
Source

singleline

Build status

Convert a multiline string to a single line string

Getting started

Install the dependency

npm install singleline --save-dev

React classNames example

import singleline from 'singleline';

...
<div
  className={singleline(`
    rrs__select-container
    rrs__select-container--multiselect
    ${(disabled === true) ? 'rrs__select-container--disabled' : ''}
    ${(isTouchDevice === true) ? 'rrs__is-touch' : 'rrs__is-desktop'}
    ${(isOptionsPanelOpen === true) ? 'rrs__options-container--visible' : ''}
    ${altered ? 'rrs__has-changed': ''}
  `)}
>
Some output
</div>

// className="rrs__select-container rrs__select-container--multiselect rrs__is-desktop rrs__options-container--visible"

Example 2

Passing second parameter in as true, removes spaces around the HTML tags but it still respects the spaces in the contents of the tags and attributes.

import singleline from 'singleline';
var testMultilineHTMLString = singleline(`

  <!DOCTYPE html>
  <html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>GDD - Giphy Github embed Gif code explorer</title>
    <link href="css/styleguide.css" rel="stylesheet">
  </head>
  <body>
    <div id="root" class="root"></div>
    <script src="app.js"></script>
  </body>
  </html>

`, true);

console.log(testMultilineHTMLString);

// '<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>GDD - Giphy Github embed Gif code explorer</title><link href="css/styleguide.css" rel="stylesheet"></head><body><div id="root" class="root"></div><script src="app.js"></script></body></html>'

Keywords

convert

FAQs

Package last updated on 13 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts